import { createRouter, createWebHistory } from 'vue-router';
// import Home from '@/views/Home.vue';

const routes = [
        {
		path: '/layout',
		component: () => import('@/layout/layout.vue'), // 指定布局
		children: [
            {
				path: '/',
				name: 'Home',
				component: () => import('@/views/home.vue')
			},
			{
				path: '/about',
				name: 'About',
				component: () => import('@/views/about/about.vue'),
				children: [
					{
						path: '/about/index',
						name: 'AboutIndex',
						component: () => import('@/views/about/index.vue')
					},
					{
						path: '/about/enterprise',
						name: 'Enterprise',
						component: () => import('@/views/about/enterprise.vue')
					},
					{
						path: '/about/develop',
						name: 'Develop',
						component: () => import('@/views/about/develop.vue')
					},
					{
						path: '/about/team',
						name: 'Team',
						component: () => import('@/views/about/team.vue')
					},
					{
						path: '/about/aptitude',
						name: 'Aptitude',
						component: () => import('@/views/about/aptitude.vue')
					},
					{
						path: '/about/liability',
						name: 'Liability',
						component: () => import('@/views/about/liability.vue')
					}
				]
			},
			{
				path: '/project',
				name: 'Project',
				component: () => import('@/views/project.vue')
			},
			{
				path: '/logistics',
				name: 'Logistics',
				component: () => import('@/views/logistics.vue')
			},
			{
				path: '/services',
				name: 'Services',
				component: () => import('@/views/services.vue')
			},
			{
				path: '/employee',
				name: 'Employee',
				component: () => import('@/views/employee.vue')
			},
			{
				path: '/hire',
				name: 'Hire',
				component: () => import('@/views/hire.vue')
			},
			{
				path: '/contact',
				name: 'Contact',
				component: () => import('@/views/contact.vue')
			},
		]
	},

	//   {
	//     path: '/project', 
	//     name: 'Project',
	//     component: () => import('@/views/project.vue'),
	//     props: true 
	//   },
	//   // 404 通配路由（必须放在最后）
	//   {
	//     path: '/:pathMatch(.*)*',
	//     name: 'NotFound',
	//     component: () => import('@/views/NotFound.vue')
	//   }
];

const router = createRouter({
	history: createWebHistory(process.env.BASE_URL),
	routes
});

router.beforeEach((to, from, next) => {
	//   if (to.name  === 'About' && !isAuthenticated()) {
	//     next('/login'); // 如果未登录，重定向到登录页
	//   } else {
	console.log('from', from.path, 'to', to.path);
	next();
	//   }
});

export default router;